using I2.Loc;
using UnityEngine;

public class MessageBox : MonoBehaviour
{
	[SerializeField]
	private UILabel msgLabel;

	[SerializeField]
	private UIButton btnOk;

	[SerializeField]
	private UIButton btnClose;

	private void Awake()
	{
		btnClose.onClick.Clear();
		EventDelegate item = new EventDelegate(OnClose);
		btnClose.onClick.Add(item);
	}

	public void Show(string messageKey, EventDelegate.Callback callback = null)
	{
		base.gameObject.SetActive(true);
		msgLabel.text = ScriptLocalization.Get(messageKey);
		btnOk.gameObject.SetActive(callback != null);
		if (callback != null)
		{
			EventDelegate item = new EventDelegate(callback);
			btnOk.onClick.Clear();
			btnOk.onClick.Add(item);
			EventDelegate item2 = new EventDelegate(OnClose);
			btnOk.onClick.Add(item2);
		}
	}

	public void ShowMessage(string message, EventDelegate.Callback callback = null)
	{
		base.gameObject.SetActive(true);
		msgLabel.text = message;
		btnOk.gameObject.SetActive(callback != null);
		if (callback != null)
		{
			EventDelegate item = new EventDelegate(callback);
			btnOk.onClick.Clear();
			btnOk.onClick.Add(item);
			EventDelegate item2 = new EventDelegate(OnClose);
			btnOk.onClick.Add(item2);
		}
	}

	public void OnClose()
	{
		base.gameObject.SetActive(false);
	}
}
